home *** CD-ROM | disk | FTP | other *** search
- From: krotoff@such.srcc.msu.su (Alexander Krotoff)
- Message-ID: <4eo2g5$7s3@boy.nmd.msu.ru>
- X-Original-Date: 31 Jan 1996 18:39:49 +0300
- Path: in2.uu.net!bounce-back
- Date: 01 Feb 96 01:51:12 GMT
- Approved: fjh@cs.mu.oz.au
- Newsgroups: comp.std.c++
- Subject: Incompatibility C++ <-> ANSI-C
- Organization: Research Computer Center, Moscow State University
- References: <4ekpnj$h7q@fsuj01.rz.uni-jena.de>
- X-Comment-To: mkt@isun04.inf.uni-jena.de
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMRAcnuEDnX0m9pzZAQF/iQGAm0apZ0nukNw5j/FFwMOmPlMPw2LEI4mS
- mSuJ/sAr7CfyqvO6Zw2Fb8aN9oy5brS7
- =okMn
-
- mkt@isun04.inf.uni-jena.de wrote:
- > Does the operator ?: an itegral promotion on its
- > second and third operand in C++?
- > I cannot find the answer in the ARM. (I think it says: no)
- >
- > Consider this:
- > char x, y;
- > Which type has the following expression:
- > (a ? x : y)
- >
- > In ANSI-C the type is clearly an 'int' (or 'unsigned').
- > But the type in C++ is 'char'???
- >
- > Even different compilers have different results!
- > (Borland 3.1: 'char', SPARCompiler 4.0: 'int')
-
- I think Borland is right.
-
- Working papers (5.16 Conditional operator) says:
-
- 2 If the second and the third operands are lvalues and have the same
- type (before any implicit conversions), the result is an lvalue of
- that type.
-
- Since both second and third operans are lvalues no implicit
- conversion will be performed.
-
- Almost the same I found in the ARM (5.16, Russian edition).
-
- --
- Alexander N. Krotoff krotoff@such.srcc.msu.su
- Research Computer Center tel: +7(095)939-2638
- Moscow State University fax: +7(095)939-4430
- ---
- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
- Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
- is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
-